package com.bw.module_motorcircle.ui.post

import com.bw.module_motorcircle.http.MotorApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

/**
 * @author ytx
 * @date 2025-09-26 09:15
 * @description
 */
class PostListRepository @Inject constructor() {
    @Inject
    lateinit var api: MotorApi
    /**
     *  检查是否关注
     */
    fun checkIfHasFocus() = flow {
        emit(api.checkIfHasFocus())
    }.flowOn(Dispatchers.IO)

    /**
     * 帖子列表
     */
    fun pageList(
        sortBy: String? = null,
        topicId: String? = null,
        memberId: String? = null,
        ifFocus: Int? = null,
        pageNum: Int,
        pageSize: Int = 10,
        keyword: String? = null
    ) = flow {
        emit(
            api.pageList(
                sortBy,
                topicId,
                memberId,
                ifFocus,
                pageNum,
                pageSize,
                keyword
            )
        )
    }.flowOn(Dispatchers.IO)
}